﻿<%@ Page Title="Calculator" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Calculators.aspx.cs" Inherits="InterestCalculation.Calculators" %>




<asp:Content runat="server" ID="Content1" ContentPlaceHolderID="MainContent">
    <div>
        <%--                <ajaxToolkit:ToolkitScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />--%>


        <table>
            <tr>
                <td colspan="3" style="flex-align: center">
                 <asp:label ID ="lblErrror" runat="server" />
                </td>
            </tr>
            <tr>
                <td colspan="3" style="flex-align: center">
                    <h1 style="flex-align: center">Loan Calculator</h1>
                </td>
            </tr>
            <tr style="flex-align: center">
                <td>
                    <asp:Button ID="btnCalculateLoan" OnClick="btnCalculateLoan_Click" runat="server" Text="Calculate Loan" />
                </td>
                <td colspan="2">
                    <asp:DropDownList ID="ddlLoanType" runat="server">
                        <asp:ListItem id="ListItem1" Value="0" Text="Weekly" />
                        <asp:ListItem id="ListItem2" Value="1" Text="Fortnightly" />
                        <asp:ListItem id="ListItem3" Value="2" Text="Monthly" />
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    <h3>Principal</h3>
                </td>
                <td>
                    <asp:TextBox ID="txtPrincipal" runat="server" />
                    <asp:RequiredFieldValidator ID="rfPrincipal" runat="server" ControlToValidate="txtPrincipal"
                        ErrorMessage='<img src="Images/ErrorMsg.jpg"/>' ToolTip="Please enter Principal"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtPrincipal"
                        ErrorMessage="Please Enter Only Numbers" Style="z-index: 101; left: 424px; position: absolute; top: 285px"
                        ValidationExpression="^\d+$" />
                </td>
            </tr>
            <tr>
                <td>
                    <h3>Loan Duration (weeks)</h3>
                </td>
                <td>
                    <asp:TextBox ID="txtLoanDurationWeeks" runat="server" />
                    <asp:RequiredFieldValidator ID="rfLoanDuration" runat="server" ControlToValidate="txtLoanDurationWeeks"
                        ErrorMessage='<img src="Images/ErrorMsg.jpg"/>' ToolTip="Please enter Loan Duration"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtLoanDurationWeeks"
                        ErrorMessage="Please Enter Only Numbers" Style="z-index: 101; left: 424px; position: absolute; top: 285px"
                        ValidationExpression="^\d+$" />
                </td>

            </tr>
            <tr>
                <td>
                    <h3>Interest Rate</h3>
                </td>
                <td>
                    <asp:TextBox ID="txtInterestRate" runat="server" />
                    <asp:RequiredFieldValidator ID="rfInterestRate" runat="server" ControlToValidate="txtInterestRate"
                        ErrorMessage='<img src="Images/ErrorMsg.jpg"/>' ToolTip="Please enter Interest Rate"></asp:RequiredFieldValidator>
                    <asp:RangeValidator ID="RangeValidator1" ControlToValidate="txtInterestRate" MinimumValue="1" MaximumValue="99"
                        Type="Integer" EnableClientScript="false" Text="Only Numberic allowed,  value must be from 1 to 99!" runat="server" />


                </td>
            </tr>
            <tr>
                <td>
                    <h3>Loan Date</h3>
                </td>
                <td>
                    <div style="width: 400px">
                        <asp:TextBox ID="txtLoanDate" runat="server" ReadOnly="true" />
                        <asp:Button ID="btnLoanDate"
                            runat="server"
                            OnClick="btnLoanDate_Click"
                            Text="+"
                            Width="30px" />

                        <asp:Calendar ID="Calendar2"
                            runat="server"
                            DayNameFormat="FirstLetter"
                            Font-Names="Arial"
                            Font-Size="11px"
                            NextMonthText="»"
                            PrevMonthText="«"
                            SelectionMode="DayWeekMonth"
                            SelectMonthText="»"
                            SelectWeekText="›"
                            CssClass="myCalendar"
                            BorderStyle="None"
                            CellPadding="1"
                            OnSelectionChanged="Calendar2_SelectionChanged"
                            Visible="False">
                            <OtherMonthDayStyle ForeColor="Gray" />
                            <DayStyle CssClass="myCalendarDay" />
                            <SelectedDayStyle Font-Bold="True" Font-Size="12px" />
                            <SelectorStyle CssClass="myCalendarSelector" />
                            <NextPrevStyle CssClass="myCalendarNextPrev" />
                            <TitleStyle CssClass="myCalendarTitle" />
                        </asp:Calendar>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <h3>First Repayment Date</h3>
                </td>
                <td>


                    <div style="width: 400px">
                        <asp:TextBox ID="txtFirstRepaymentDate" runat="server" ReadOnly="true" />

                        <asp:Button ID="btnFirstRepaymentDate"
                            runat="server"
                            OnClick="btnFirstRepaymentDate_Click"
                            Text="+"
                            Width="30px" />

                        <asp:Calendar ID="Calendar1"
                            runat="server"
                            DayNameFormat="FirstLetter"
                            Font-Names="Arial"
                            Font-Size="11px"
                            NextMonthText="»"
                            PrevMonthText="«"
                            SelectionMode="DayWeekMonth"
                            SelectMonthText="»"
                            SelectWeekText="›"
                            CssClass="myCalendar"
                            BorderStyle="None"
                            CellPadding="1"
                            OnSelectionChanged="Calendar1_SelectionChanged"
                            Visible="False">
                            <OtherMonthDayStyle ForeColor="Gray" />
                            <DayStyle CssClass="myCalendarDay" />
                            <SelectedDayStyle Font-Bold="True" Font-Size="12px" />
                            <SelectorStyle CssClass="myCalendarSelector" />
                            <NextPrevStyle CssClass="myCalendarNextPrev" />
                            <TitleStyle CssClass="myCalendarTitle" />
                        </asp:Calendar>

                        <style type="text/css">
                            .myCalendar {
                                background-color: #efefef;
                                width: 200px;
                                position: absolute;
                                z-index: 1;
                            }

                                .myCalendar a {
                                    text-decoration: none;
                                }

                                .myCalendar .myCalendarTitle {
                                    font-weight: bold;
                                }

                                .myCalendar td.myCalendarDay {
                                    border: solid 2px #fff;
                                    border-left: 0;
                                    border-top: 0;
                                }

                                .myCalendar .myCalendarNextPrev {
                                    text-align: center;
                                }

                                .myCalendar td.myCalendarSelector {
                                    background-color: #dddddd;
                                }

                                .myCalendar .myCalendarDay a,
                                .myCalendar .myCalendarSelector a,
                                .myCalendar .myCalendarNextPrev a {
                                    display: block;
                                    line-height: 18px;
                                }

                                    .myCalendar .myCalendarDay a:hover,
                                    .myCalendar .myCalendarSelector a:hover {
                                        background-color: #cccccc;
                                    }

                                    .myCalendar .myCalendarNextPrev a:hover {
                                        background-color: #fff;
                                    }
                        </style>
                    </div>

                </td>
            </tr>
            <tr>
                <td>
                    <h3>Repayment</h3>
                </td>
                <td>
                    <asp:Label ID="lblRepayment" runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    <h3>No of Repayments</h3>
                </td>
                <td>
                    <asp:Label ID="lblNoofRepayments" runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    <h3>Total Interest</h3>
                </td>
                <td>
                    <asp:Label ID="lblTotalInterest" runat="server" />
                </td>
            </tr>
            <tr>
                <td colspan="2">

                    <asp:GridView ID="gvLoanDetails" runat="server" AutoGenerateColumns="False" GridLines="Both" EmptyDataText="No Loan information available">
                        <Columns>
                            <asp:BoundField DataField="Line" HeaderText="Pay" />
                            <asp:BoundField DataField="Date" HeaderText="Date" DataFormatString="{0:MMMM d, yyyy}" HtmlEncode="false" />
                            <asp:BoundField DataField="Payment" HeaderText="Payment" />
                            <asp:BoundField DataField="Charges" HeaderText="Charges" />
                            <asp:BoundField DataField="Balance" HeaderText="Balance" />
                            <asp:BoundField DataField="Interest" HeaderText="Interest" />
                        </Columns>
                    </asp:GridView>
                </td>
            </tr>
        </table>




    </div>

</asp:Content>

